package com.controller;

import com.model.AppVersionUpgrade;
import com.page.GenericPage;
import com.po.DeviceRepairApplyPO;
import com.po.DeviceRepairApplyQueryConditionPO;
import com.result.Result;
import com.service.DeviceRepairApplyService;
import com.vo.DeviceRepairApplyVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: chihaojie
 * @Date: 2019/6/18 8:32
 * @Version 1.0
 * @Note  设备报修相关接口
 *
 */

@Api(value="deviceRepairApi",tags={"DeviceRepair"})
@CrossOrigin
@RestController
@RequestMapping("/deviceRepair")
public class DeviceRepairApplyController {


    @Autowired
    private DeviceRepairApplyService  deviceRepairApplyService;


    /**
     * 分页查询报修记录
     */
    @ApiOperation(value = "分页查询报修记录接口", httpMethod = "POST", notes = "分页查询报修记录接口-多条件查询")
    @RequestMapping(value = "/getDeviceRepairApplyPage",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<GenericPage<DeviceRepairApplyVO>> getDeviceRepairApplyPage(@RequestBody DeviceRepairApplyQueryConditionPO queryConditionPO,
                                                                             @RequestParam(value = "pageNo", defaultValue = "1") int pageNo,
                                                                             @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
        return deviceRepairApplyService.getDeviceRepairApplyPage(queryConditionPO,pageNo,pageSize);
    }


    /**
     * 查询详情接口
     */
    @ApiOperation(value = "查询详情接口", httpMethod = "GET", notes = "查询详情接口")
    @RequestMapping(value = "/getDeviceRepairApplyDetail", method = RequestMethod.GET)
    public Result<DeviceRepairApplyVO> getDeviceRepairApplyDetail(@RequestParam("id") Long id) {
        return deviceRepairApplyService.getDeviceRepairApplyDetail(id);
    }

    /**
     * 故障状态处理接口
     */
    @ApiOperation(value = "故障状态处理接口", httpMethod = "GET", notes = "故障状态处理接口")
    @RequestMapping(value = "/troubleShootStatus", method = RequestMethod.GET)
    public Result<Boolean> troubleShootStatus(@RequestParam("id") Long id,@RequestParam("troubleShootStatus") Integer  troubleShootStatus) {
        return deviceRepairApplyService.troubleShootStatus(id,troubleShootStatus);
    }



    /**
     * 报修接口
     */
    @ApiOperation(value = "报修接口", httpMethod = "POST", notes = "报修接口")
    @RequestMapping(value = "/repair",method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<Boolean> repair(@RequestBody DeviceRepairApplyPO repairApplyPO) {
        return deviceRepairApplyService.repair(repairApplyPO);
    }

}
